﻿using System;
using System.Windows;
using System.ComponentModel.Composition;
using Caliburn.Micro;

namespace csExcel
{
    [Export(typeof(IShell))]
    public class ShellViewModel:IShell
    {
        readonly IWindowManager windowManager;

        [ImportingConstructor]
        public ShellViewModel(IWindowManager windowManager)
        {
            this.windowManager = windowManager;
        }

        public void ImportExcel()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".xls";
            dlg.Filter = "Excel Files(*.xls,*.csv)|*.xls;*.csv|2007 Excel Files(*.xlsx)|*.xlsx";
            Nullable<bool> result = dlg.ShowDialog();
            if (result==true)
            {
                views.ImportExcelViewModel importExcel = new views.ImportExcelViewModel(dlg.FileName);
                windowManager.ShowDialog(importExcel);
                importExcel.Dispose();                
            }
        }
    }
}
